// $Id$
// Licensed under Apache License Version 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0.html
package de.servicezombie.tcmdb.util;

import de.servicezombie.lang.Configuration;
import de.servicezombie.tcmdb.ConfigurationConstants;
import de.servicezombie.tcmdb.rest.vo.WsApplication;
import de.servicezombie.tcmdb.rest.vo.WsTestExecution;
import de.servicezombie.tcmdb.rest.vo.WsTestcaseDefinition;

public abstract class TestExecutionUtils {

	public static void copyValuesFromDefinition(WsTestcaseDefinition definition, WsTestExecution execution) {

		for (WsApplication application : definition.getApplications()) {
			execution.addApplication(application);
		}
		execution.setAccess(definition.getAccess());
		execution.setDescription(definition.getDescription());
		execution.setEffort(definition.getEffort());
		execution.setExpectedResult(definition.getExpectedResult());
		execution.setGroup(WsTestExecution.UNKNOWN_GROUP);
		execution.setKnownBugs(definition.getKnownBugs());
		execution.setOwner(definition.getOwner());
		execution.setReferencedDefinitionId(definition.getId());
		execution.setSeverity(definition.getSeverity());
		execution.setStatus(definition.getStatus());
		execution.setSteps(definition.getSteps());
		execution.setTags(definition.getTags());
		execution.setTitle(definition.getTitle());

	}
	
	public static String getDefaultResolution(Configuration configuration) {
		return configuration.getStringArray(ConfigurationConstants.KNOWN_RESOLUTION_STATES)[0];
	}

	public static String[] getKnownResolutions(Configuration configuration) {
		return configuration.getStringArray(ConfigurationConstants.KNOWN_RESOLUTION_STATES);
	}
}
